package priyank.patel.bottomnavigationdemo;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.view.ViewGroup;
import android.app.Activity;
import android.app.ActivityManager;
import android.os.Bundle;
import android.text.method.ScrollingMovementMethod;
import android.content.Context;
import java.util.List;
/**
 * Created by priyank on 16/11/16.
 */

public class MusicFragment extends Fragment {
    private View view;
    public MusicFragment() {
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		
        view= inflater.inflate(R.layout.fragment_music, container, false);
		

        ActivityManager activityManager = (ActivityManager)getActivity().getSystemService(Context.ACTIVITY_SERVICE);

  /*
   * maxNum: the maximum number of entries to return in the list.
   * The actual number returned may be smaller,
   * depending on how many services are running.
   */
        int maxNum = 100;
        List<ActivityManager.RunningServiceInfo> list = activityManager.getRunningServices(maxNum);

        StringBuilder info = new StringBuilder();

        info.append("Services currently running: " + list.size() + "\n\n");
        for(int i=0; i<list.size(); i++){
            info.append(list.get(i).service + "\n\n");
        }

        TextView texView =  (TextView) view.findViewById(R.id.info);
        texView.setMovementMethod(new ScrollingMovementMethod());
        texView.setText(info);

        return view;		
    }
}

